﻿using UnityEngine;
using System.Collections;

namespace AutoRoot
{
   public class ScaleToFullScreen : MonoBehaviour
   {

      // Use this for initialization
      public void Start()
      {
         //Scale to 100% screen width & height
         float targetSizeX = Vector3.Distance(Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, 0f)), Camera.main.ViewportToWorldPoint(new Vector3(1f, 0f, 0f)));
         float targetSizeY = Vector3.Distance(Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, 0f)), Camera.main.ViewportToWorldPoint(new Vector3(0f, 1f, 0f)));
         Vector3 scale = transform.localScale;
         scale.x = targetSizeX * scale.x / renderer.bounds.size.x;
         scale.y = targetSizeY * scale.y / renderer.bounds.size.y;
         transform.localScale = scale;
      }
   }
}